#ifndef SERIALPORTFORM_H
#define SERIALPORTFORM_H

#include <QWidget>
#include "InputParameter.h"
#include <QSerialPort>

namespace Ui {
class SerialPortForm;
}

class SerialPortForm : public QWidget
{
    Q_OBJECT

public:
    explicit SerialPortForm(QWidget *parent = nullptr);
    ~SerialPortForm();

    bool IsOpen(){
        if(this->m_serial && this->m_serial->isOpen()){
            return true;
        }
        return false;
    };

public:
    void Send(const stParameter& parameter);

protected slots:

    void on_comboBox_port_currentIndexChanged(int index);

    void on_comboBox_baund_currentIndexChanged(int index);

    void slot_pushButton_open_clicked();

    void on_pushButton_flush_clicked();

signals:
    void SigData(const QByteArray& data);

private:
    Ui::SerialPortForm *ui;
    QSerialPort* m_serial;

    QString m_portName;
    int m_baundRate;
    bool IsBreakConnect;
};

#endif // SERIALPORTFORM_H
